﻿using System;
using System.Collections.Generic;
using NUnit.Framework;
using Xenta.Enums;
using Xenta.Operations;

namespace Xenta.Tests.Operations
{
    [TestFixture]
    public class CatalogItemGroupTests : OperationTest
    {
        protected override IEnumerable<Type> ModelMappings
        {
            get
            {
                return NHMappings.ALL;
            }
        }

        [Test]
        public void Can_CRUD()
        {
            var group = Processor.Execute(new CreateCatalogItemGroup
            {
                SupplierID = Processor.Execute(new CreateCatalogSupplier()).Result.EntityID
            }).Result;

            Assert.NotNull(group);
            group.AreEqual(Processor.Execute(new GetCatalogItemGroup
            {
                EntityID = group.EntityID
            }).Result);

            var upd_group = Processor.Execute(new UpdateCatalogItemGroup
            {
                EntityID = group.EntityID,
                Flags = CatalogItemGroupFlags.Active
            }).Result;

            Assert.NotNull(upd_group);
            upd_group.AreEqual(group);
            upd_group.Flags.AreEqual(CatalogItemGroupFlags.Active);

            Processor.Execute(new DeleteCatalogItemGroup
            {
                EntityID = group.EntityID
            });
        }
    }
}
